package com.jingdianjichi.auth.domain.service.Impl;


import com.jingdianjichi.auth.common.enums.IsDelectdFlagEnum;
import com.jingdianjichi.auth.domain.convert.AuthRoleConvertBO;
import com.jingdianjichi.auth.domain.entity.AuthRoleBO;
import com.jingdianjichi.auth.domain.service.AuthRoleDomainService;
import com.jingdianjichi.auth.infa.basic.entity.AuthRole;
import com.jingdianjichi.auth.infa.basic.service.AuthRoleService;

import org.springframework.stereotype.Service;

import javax.annotation.Resource;


@Service
public class AuthRoleDomainServiceImpl implements AuthRoleDomainService {


    @Resource
    private AuthRoleService accountRoleService;

    @Override
    public Boolean add(AuthRoleBO authRoleBO) {
        AuthRole authRole = AuthRoleConvertBO.INSTANCE.convertBOToEntity(authRoleBO);
        authRole.setIsDeleted(IsDelectdFlagEnum.UN_DELETED.getCode());
        Integer count = accountRoleService.insert(authRole);
        return count>0;
    }

    @Override
    public Boolean update(AuthRoleBO authRoleBO) {
        AuthRole authRole = AuthRoleConvertBO.INSTANCE.convertBOToEntity(authRoleBO);
        Integer count = accountRoleService.update(authRole);
        return count>0;
    }

    @Override
    public Boolean delete(AuthRoleBO authRoleBO) {
        AuthRole authRole = AuthRoleConvertBO.INSTANCE.convertBOToEntity(authRoleBO);
        authRole.setIsDeleted(IsDelectdFlagEnum.DELETED.getCode());
        Integer count = accountRoleService.update(authRole);
        return count>0;
    }
}
